package org.elsfs.framework.event.support;

import java.util.Comparator;

/**
 * Event比较
 *
 * @author zeng
 * @since 0.0.1
 */
public class EventClassComparator implements Comparator<Class> {

  @Override
  @SuppressWarnings("unchecked")
  public int compare(Class a, Class b) {
    if (a == null) {
      if (b == null) {
        return 0;
      } else {
        return -1;
      }
    } else if (b == null) {
      return 1;
    } else if (a == b || a.equals(b)) {
      return 0;
    } else {
      if (a.isAssignableFrom(b)) {
        return 1;
      } else if (b.isAssignableFrom(a)) {
        return -1;
      } else {
        return 0;
      }
    }
  }
}
